<?php

// +----------------------------------------------------------------------
// |设置管理管理控制器
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\BaseController;
use think\facade\View;
use app\common\system\ConfigService;
use  app\common\Model\StroageModel;


class Config extends BaseController
{
    // 设置列表
    public function index()
    { 
          //仓库的信息    
        $storagelist =(new StroageModel())->getActiveStatus();       
        if(request()->isPost()){
            $param = request()->post();
            $data= ConfigService::list($param);  
         
            if($data['list']){             
                foreach($data['list'] as $k=>$v){              ;
                  $data['list'][$k]['storage_name']=isset($storagelist[$v['storage_id']])?$storagelist[$v['storage_id']]['name']:'无';
                }
              }
            success($data);
        }else{
            View::assign('storages', json_encode( $storagelist));
          return View::fetch();
        }      
    }

    public function get_list(){
        $param = request()->post();
        $params['params']['id']= $param['params'];    
        $data= ConfigService::get_list($params);   
        success($data);
    }

    // 设置添加与修改
    public function create()    {
       
        if(request()->isPost()){
            $param = request()->post();
            $data= ConfigService::create($param);        
            success($data);
        }
        
    }
    

    // //设置删除
    // public function delete()
    // {
    //     if(request()->isPost()){
    //         $param = request()->post(); 
    //         $data= ConfigService::delete($param);        
    //         success($data);
    //     }
    // }

    //单位列表
    public function measures(){
       if(request()->isPost()){
            $param = request()->post(); 
            $data= ConfigService::measures($param);        
            success($data);
        }else{
            return View::fetch();
        }
    }
    //售后的模板
    public function aftersale_template(){
         if(request()->isPost()){
            $param = request()->post(); 
            $data= ConfigService::aftersale_template($param);        
            success($data);
        }else{
            return View::fetch();
        }
    }
     //国家列表
    public function country_list(){
         if(request()->isPost()){
            $param = request()->post(); 
            $data= ConfigService::country_list($param);        
            success($data);
        }else{
            return View::fetch();
        }
    }
   
}
